//---------------------------------------------------------------------------

#ifndef ProviderBridgeH
#define ProviderBridgeH

#include <dbtables.hpp>
#include "StringUtilities.h"

class TProvider : public TObject
{
   public:
      __int64 id;
      AnsiString name;
      AnsiString address;
      AnsiString phone;

      TProvider();
      TProvider( TProvider* other);
};

class TProviderBridge
{
   public:
      TProviderBridge( TDatabase * database);
      ~TProviderBridge();

      void Get( __int64 id, TProvider* provider);
      void Add( TProvider* provider);
      void Update( TProvider* provider);
      void Delete( __int64 id);
      void GetProviders( TStrings * providers);
      bool InUse( TProvider* provider);

   private:
      TQuery * qryGet;
      TQuery * qryAdd;
      TQuery * qryUpdate;
      TQuery * qryDelete;
      TQuery * qryGetProviders;
      TQuery * qryInUse;

      void BuildGetQuery();
      void BuildAddQuery();
      void BuildUpdateQuery();
      void BuildDeleteQuery();
      void BuildGetProvidersQuery();
      void BuildInUseQuery();
};

#endif
